//package service.demo;
//
//import mapper.userMapper;
//import org.apache.ibatis.session.SqlSession;
//import org.apache.ibatis.session.SqlSessionFactory;
//import pojo.User;
//import util.factory;
//
//public class userService {
//    //获取工厂
//    factory f=new factory();
//    SqlSessionFactory sqlSessionFactory=f.getSqlSessionFactory();
//    public User login(String username, String password){
//        //获取sqlSession
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        //获取类，并执行SQL
//        userMapper mapper = sqlSession.getMapper(userMapper.class);
//        User user = mapper.login(username,password);
//        sqlSession.close();
//        return user;
//    }
//    public boolean selectByUsername(String username){
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        userMapper mapper = sqlSession.getMapper(userMapper.class);
//        User user = mapper.selectByUsername(username);
//        sqlSession.close();
//        if (user!=null){
//            return true;
//        }else {
//            return false;
//        }
//
//    }
//    public void add(User user){
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        userMapper mapper = sqlSession.getMapper(userMapper.class);
//        mapper.add(user);
//        sqlSession.commit();
//        sqlSession.close();
//    }
//}
